gh-144766: Fix a crash in fork child process when perf support is enabled.#144795
gh-144766: Fix a crash in fork child process when perf support is enabled.#144795pablogsal merged 2 commits intopython:mainfrom
Conversation
|
The macOS free-threading test failures seem unrelated. |
pablogsal
left a comment
There was a problem hiding this comment.
This makes sense to me! Thanks for taking the time to produce a good test for this and the excellent investigation and the fix ❤️
|
Thanks @yilei for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…is enabled. (pythonGH-144795) (cherry picked from commit 5922149a5033ec1151320864e605adf88f53f280) Co-authored-by: Yilei <hi@mangoumbrella.com>
|
Sorry, @yilei and @pablogsal, I could not cleanly backport this to |
|
GH-144816 is a backport of this pull request to the 3.14 branch. |
|
@yilei can you try to follow the instructions to do the 3.13 backport by hand? Otherwise I can do it later today so no worries :) |
…upport is enabled. (pythonGH-144795) (cherry picked from commit 5922149) Co-authored-by: Yilei <hi@mangoumbrella.com>
|
GH-144818 is a backport of this pull request to the 3.13 branch. |
I can get to it ~Monday if you haven't done so then. |
|
Why? After fork,
_PyPerfTrampoline_Finimay leave the old code watcher registered if trampolined code objects from the parent still exist (trampoline_refcount> 0).This change clears it unconditionally before
_PyPerfTrampoline_Initregisters a new one, to prevent two watchers sharing the same globals and double-decrementingtrampoline_refcount.Also added
test_trampoline_works_after_fork_with_many_code_objects, and verified it fails before the fix.